<!-- JSP to modify a department -->
<%@ page import="sg.edu.nus.iss.cats.controller.*,sg.edu.nus.iss.cats.model.*,sg.edu.nus.iss.cats.dataaccess.DAOException"%>

<%
    String departmentId = request.getParameter("departmentid");
    String managerInCharge = request.getParameter("managerincharge");   
              
    if (departmentId == null || managerInCharge == null || departmentId.equals("") || managerInCharge.equals("")){
        HTMLUtil.displayException(request,response,"Sorry, the department details could not be updated. \n Please check the department id and manager-in-charge.....");
        return;

    }
    
    Department newDepartment = new Department();  
    newDepartment.setDepartmentId(departmentId);
    newDepartment.setManagerInCharge(managerInCharge);


    try{
        DepartmentManager departmentManager = new DepartmentManager();
        departmentManager.updateDepartment (newDepartment);

    }catch(DAOException e){
        HTMLUtil.displayException(request,response,"Sorry, there was an error updating the department details.");
        return;

    }
 %>
 
 
 <jsp:forward page="/admin/displayDept"/>
            